package crawl.http;

import java.lang.reflect.Field;

import utils.Logger;

public class TagWeight
{
    private static TagWeight instance = new TagWeight();
    public static int        TITLE    = 40;
    public static int        H1       = 12;
    public static int        CITE     = 8;
    public static int        H2       = 8;
    public static int        DT       = 4;
    public static int        LI       = 4;
    public static int        UL       = 4;
    public static int        STRONG   = 4;
    public static int        A        = 4;
    public static int        B        = 4;
    public static int        BIG      = 4;
    public static int        H3       = 3;
    public static int        EM       = 2;
    public static int        I        = 2;
    public static int        H4       = 1;
    public static int        H5       = 1;

    public static int getWeight(String tag)
    {
        Class<TagWeight> c = TagWeight.class;
        try
        {
            Field field = c.getField(tag);
            return field.getInt(instance);
        }
        catch (IllegalAccessException e)
        {
            Logger.logException(e, true);
            return 0;
        }
        catch (SecurityException e)
        {
            Logger.logException(e, true);
            return 0;
        }
        catch (NoSuchFieldException e)
        {
            //Logger.logException(e);
            return 0;
        }
    }
}
